import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primaryColor: Colors.red),
      home: Scaffold(
        appBar: AppBar(title: const Text('Flutter app')),
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Flex(
      direction: Axis.horizontal,
      // children: [
      //   Expanded(
      //     flex: 1,
      //     child: IconContainer(Icons.ac_unit, color: Colors.yellow),
      //   ),
      //   Expanded(
      //     flex: 2,
      //     child: IconContainer(Icons.home_outlined, color: Colors.red),
      //   ),
      // ],
      children: [
        Expanded(
          flex: 1,
          child: IconContainer(Icons.ac_unit, color: Colors.red),
        ),
        IconContainer(Icons.home_outlined, color: Colors.blue),
      ],
    );
  }
}

// 自定义区块
class IconContainer extends StatelessWidget {
  final IconData icon;
  final Color color;
  const IconContainer(this.icon, {super.key, required this.color});

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      width: 200,
      height: 400,
      color: color,
      child: Icon(icon, color: Colors.white, size: 28),
    );
  }
}
